package com.wzg.pldroidplayer.recyclerviewdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;

import com.wzg.pldroidplayer.recyclerviewdemo.Adapter.MyAdapter;
import com.wzg.pldroidplayer.recyclerviewdemo.Util.ToastUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private List<String> stringList;
    private MyAdapter myAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //初始化数据
        initData();
        //设置初始化RecyclerView
        initRecyclerView();

    }

    // TODO: 2018/4/12 设置初始化RecyclerView
    private void initRecyclerView() {
        recyclerView = findViewById(R.id.RecyclerViewId);
         // 设置固定大小
        recyclerView.setHasFixedSize(true);
        // 设置为错列网格布局实现瀑布流
        recyclerView.setLayoutManager(
                new StaggeredGridLayoutManager(
                        3,StaggeredGridLayoutManager.VERTICAL
                ));
        // 设置适配器




        myAdapter = new MyAdapter(stringList);
        recyclerView.setAdapter(myAdapter);
        // 添加装饰

        // 设置为默认动画

    }

    // TODO: 2018/4/12 初始化Data
    private void initData() {
        stringList = new ArrayList<>();
        for (int i = 1; i <= 1000; i++) {
            String data = "No." + i;
            stringList.add(data);
        }
    }
}
